function fiboEvenSum(n) {
    let fib = [1, 1];
    while (fib[fib.length - 1] < n) {
        fib.push(fib[fib.length - 1] + fib[fib.length - 2]);
    }
    //console.log(fib);
    return fib.filter((x) => x % 2 === 0)
        .reduce((x, y) => x + y);
}

console.log(fiboEvenSum(8))